package org.erp.procurement.enums;

import lombok.Getter;

/**
 * 采购订单状态
 *
 * @author libin
 * @version 1.0
 * @description: 采购订单状态
 * @date 2025/11/5 11:30
 **/
@Getter
public enum OrderStatusEnum {
    TO_BE_SHIPPED(0, "待发货"),
    QUALITY_INSPECTION(1, "质检中"),
    TO_BE_CONFIRMED(2, "待确认"),
    DONE(3, "已完成"),
    CANCELLED(4, "已取消");

    private final Integer code;
    private final String message;

    OrderStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer getCodeByMessage(String message) {
        for (OrderStatusEnum item : OrderStatusEnum.values()) {
            if (item.getMessage().equals(message)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (OrderStatusEnum item : OrderStatusEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getMessage();
            }
        }
        return null;
    }

    public static OrderStatusEnum getByCode(Integer code) {
        for (OrderStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static OrderStatusEnum getByMessage(String message) {
        for (OrderStatusEnum value : values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return null;
    }
}
